package Protocol
{
	import flash.utils.ByteArray;
	import KK.Data.ProtocolData;


	public class CTest extends ProtocolData
	{
		private var exp:int;
		private var id:uint;
		private var name:String;
		private var money:uint;
		private var sex:uint;
		private var isActive:Boolean;

		public function Serialize(bytes:ByteArray):void
		{
			var i:int = 0;
			var len:int = 0;

			bytes.writeInt(exp);
			bytes.writeInt(id);
			bytes.writeShort(name.length);
			bytes.writeMultiByte(name,'utf-8');
			bytes.writeShort(money);
			bytes.writeByte(sex);
			bytes.writeBoolean(isActive);
		}


		public function Unserialize(bytes:ByteArray):void
		{
			var len:int = 0;
			var i:int = 0;

			exp = bytes.readInt();
			id = bytes.readInt();
			len = bytes.readShort();
			name = bytes.readMultiByte(len, "utf-8");
			money = bytes.readShort();
			sex = bytes.readByte();
			isActive = bytes.readBoolean();
		}


		public function getSize():uint
		{
			var result:uint = 0;
			var i:int = 0;
			var len:int = 0;

			result += INT32;
			result += INT32;
			result += INT16 + name.length;
			result += INT16;
			result += CHAR;
			result += CHAR;
			return result;
		}

	};
}

